import request from "@/utils/request";
import type { skuListType, skuInfoType } from "./spu";
//sku列表信息类型
export interface skuListInfoType {
  records: skuListType;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
}

//1. 请求sku列表接口
export const reqSkuList = (page: number, limit: number) => {
  return request.get<null, skuListInfoType>(
    `/admin/product/list/${page}/${limit}`
  );
};

//2. 上架sku
export const reqOnSale = (skuId: number) => {
  return request.get<null, null>(`/admin/product/onSale/${skuId}`);
};

//2. 下架sku
export const reqCancelSale = (skuId: number) => {
  return request.get<null, null>(`/admin/product/cancelSale/${skuId}`);
};

//3. 根据skuId查看sku的详细信息
export const reqSkuDetail = (skuId: number) => {
  return request.get<null, skuInfoType>(`/admin/product/getSkuById/${skuId}`);
};

//4. 删除某个sku
export const reqDeleteSku = (skuId: number) => {
  return request.delete<null, null>(`/admin/product/deleteSku/${skuId}`);
};
